#include"List.h"
void SLinit(SL* nodata)
{
	assert(nodata);
	nodata->nest = (Data*)malloc(sizeof(Data));
	assert(nodata);
	nodata->Datadeep = 1;
	//nodata->nest = NULL;
	nodata->top = 0;
}
void memdata(SL* data)
{
	assert(data);
	Data* tmp =  (Data*)realloc(data->nest, sizeof(data->nest)*data->Datadeep * 2);
	if (realloc == NULL)
	{
		perror("realloc");
		return;
	}
	data->nest = tmp;
	data->Datadeep = data->Datadeep * 2;
}
void SLpush(SL* data,Data x)
{
	assert(data);
	if (data->top  == data->Datadeep)
	{
		memdata(data);
		assert(data);
	}
	data->nest[data->top] = x;
	data->top++;
}
bool STEmpyt(SL* data)
{
	assert(data);
	return data->top == 0;
}
Data STTop(SL* data)
{
	assert(data);
	assert(!STEmpyt(data));
	return data->nest[data->top - 1];
}
void SLDestroy(SL* data)
{
	assert(data);
	free(data->nest);
	data->nest= NULL;
	data->top = 0;
	data->Datadeep = 0;
}
void SLpop(SL* data)
{
	assert(data);
	//SLPopDestroy(data);
	if (data->top == 0)
	{
		return;
	}
	data->top--;
	
}
//void SLprin(SL* data)
//{
//	assert(data);
//	if (data->top == 0)
//	{
//		return;
//	}
//	int n = data->top;
//	for(n=data->top-1;n>=0;n--)
//	{
//		printf("%d ", STTop(data));
//		data->top--;
//	}
//}
